<html>
<head><meta charset="utf-8"><title>Remove Spans from HIR compiler-team#294 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html">Remove Spans from HIR compiler-team#294</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198050067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198050067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198050067">(May 19 2020 at 11:09)</a>:</h4>
<p>A new proposal has been announced <a href="https://github.com/rust-lang/compiler-team/issues/294">#294</a>. It will be brought up at the next meeting.</p>



<a name="198100235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198100235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198100235">(May 19 2020 at 17:27)</a>:</h4>
<p><span class="user-mention" data-user-id="248906">@cjgillot</span> what is the latest estimate of perf impact on this?</p>



<a name="198100843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198100843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198100843">(May 19 2020 at 17:32)</a>:</h4>
<p>I lost access to my other computer, so I can't measure locally. I just pushed a hopefully faster solution.</p>



<a name="198374745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198374745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198374745">(May 21 2020 at 20:43)</a>:</h4>
<p>hey <span class="user-mention" data-user-id="248906">@cjgillot</span> , I wanted to double-check with you about some aspects of this MCP</p>



<a name="198374935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198374935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198374935">(May 21 2020 at 20:45)</a>:</h4>
<p>in particular, one thing I need to straighten out in my own mind is how we get the desired benefit (more incremental compilation) while not losing any current features. Specifically: when code layout (and thus spans) change in ways that otherwise do not affect semantics, what is your expectation? That the HIR will be unchanged (and computational queries based on it reused), but the side-table will be updated?</p>



<a name="198374974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198374974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198374974">(May 21 2020 at 20:45)</a>:</h4>
<p>Is the above is correct, does your preliminary <a href="https://github.com/rust-lang/rust/issues/72015">#72015</a> actually implement such side-table updating?</p>



<a name="198379548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198379548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198379548">(May 21 2020 at 21:26)</a>:</h4>
<p>Yes, the idea is to have the HIR remain the same, and only the side table should change. <br>
<a href="https://github.com/rust-lang/rust/issues/72015">#72015</a> implements this partially: I have not removed all the spans from HIR. For now, I only handle those with an associated HirId.</p>



<a name="198379894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198379894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198379894">(May 21 2020 at 21:30)</a>:</h4>
<p>Actually, after the 5th commit in <a href="https://github.com/rust-lang/rust/issues/72015">#72015</a>, the side table is completely built. All the other commits are dedicated to removing spans from the HIR.</p>



<a name="198398495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/198398495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#198398495">(May 22 2020 at 01:35)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="492">@T-compiler</span>: Proposal <a href="https://github.com/rust-lang/compiler-team/issues/294#issuecomment-632430017">#294</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="199040778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/199040778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#199040778">(May 28 2020 at 15:47)</a>:</h4>
<p>There might be potential interactions with <a href="https://github.com/rust-lang/rust/issues/72625">#72625</a> which adds a <code>Vec&lt;Span&gt;</code> to <code>InlineAsm</code> HIR and MIR nodes that contains the source spans for each line of the inline asm. This is passed to LLVM in codegen which allows assembler errors to be mapped back to a source line.</p>



<a name="199041337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/199041337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#199041337">(May 28 2020 at 15:52)</a>:</h4>
<p>Also <code>InlineAsmTemplatePiece</code> is passed through all of the layers (HIR, MIR) and contains a <code>Span</code> that points to the individual placeholders (<code>{}</code>) in the asm template string. This span is only used for diagnostics in AST lowering and in the intrinsicsck pass (just after typeck, before MIR).</p>



<a name="199043757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/199043757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#199043757">(May 28 2020 at 16:12)</a>:</h4>
<p>I don't think this is a pressing issue. Inline ASM has very specific needs, and is not of very wide use, so it is at the end of my roadmap. I will look for a solution, but keeping the <code>Vec&lt;Span&gt;</code> should be fine.</p>



<a name="200511459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200511459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200511459">(Jun 11 2020 at 07:09)</a>:</h4>
<p>I am stuck with the regression in <a href="https://github.com/rust-lang/rust/issues/72878">#72878</a>. Stable hashing of the spans seems to be one of the reasons. Does somebody have a suggestion on how to reduce its impact ?</p>



<a name="200947406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947406">(Jun 15 2020 at 21:20)</a>:</h4>
<p><span class="user-mention" data-user-id="248906">@cjgillot</span> I'm not sure, but can you say a bit more about why we have to stable hash the spans? Is it that we are hashing the spans that we see as the return type of queries? I guess I have to review the overall plan here, I forget the details.</p>



<a name="200947490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947490">(Jun 15 2020 at 21:21)</a>:</h4>
<p>When talking to <span class="user-mention" data-user-id="225192">@Nell Shamrell-Harrington</span> today about an unrelated issue, I realized that an advantage of this approach is that, whenever you have a span, you would also have the <code>hir_id</code> of an expression, which is potentially quite useful in error reporting, since you can then analyze the source expression in a more structured way (cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span>).</p>



<a name="200947554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947554">(Jun 15 2020 at 21:22)</a>:</h4>
<p>Well, maybe not <em>whenever</em>, but more often anyway.</p>



<a name="200947574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947574">(Jun 15 2020 at 21:22)</a>:</h4>
<p>Yes, it happens at the return of the query.</p>



<a name="200947745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947745">(Jun 15 2020 at 21:24)</a>:</h4>
<p>The query is indexed using a local defid, and returns a vector of all the spans it owns. The latter can be sizeable.</p>



<a name="200947843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/200947843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#200947843">(Jun 15 2020 at 21:24)</a>:</h4>
<p>There may be other sources of slowness. This the one I have identified.</p>



<a name="201710296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Remove%20Spans%20from%20HIR%20compiler-team%23294/near/201710296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Remove.20Spans.20from.20HIR.20compiler-team.23294.html#201710296">(Jun 23 2020 at 10:40)</a>:</h4>
<p>Hi, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span>. I did not manage to remove the perf regression. I still have a ~4% regression (~ 10ms) on many benchmarks. I would welcome some ideas.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>